﻿using System;

namespace Mbs.Factories
{
    public class DelegateFactory<TInput,TTarget>:FactoryBase<TInput,TTarget>
    {
        private readonly Func<TInput, TTarget> instaceCreator;

        public DelegateFactory(Func<TInput, TTarget> creator)
        {
            instaceCreator = creator;
        }

        public override TTarget Create(TInput input)
        {
            if (instaceCreator == null) return default(TTarget);
            return instaceCreator(input);
        }
    }
}
